# -*- coding: utf-8 -*-
__author__ = 'Jinkey'
import json

data1 = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]

data2 = [((1,2),(3,4))]
for a,b in data2:
    print a,b

def cross_validation(fold, data):
    if type(fold) != int or type(data) != list:
        raise TypeError
    else:
        each_amount = len(data)/fold
        result = []
        for x in range(0, 5):
            test_set = tuple(data[x * each_amount: (x + 1) * each_amount])
            train_set = tuple([item for item in data if item not in test_set])
            # print type(test_set)
            each = tuple((train_set, test_set))
            result.append(each)
        print result
        return result

for each in cross_validation(5, data1):
    print type(each)
    for train_set, test_set in each:
        print type(train_set)
        print type(test_set)
        # print "train_set is : " + str(train_set)
        # print "test_set is : " + str(test_set)
